package cn.demo.service0.source;

import cn.demo.service0.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @Author: ljh
 * @Date: 2019/11/6 20:26
 */

@Component
@Slf4j
@EnableBinding(Source.class)
public class SimpleSourceBean {
    @Autowired
    private Source source;
    public void publishOrgChandge(User user) {
        log.info("send msg kafka {} ", user);
        source.output().send(MessageBuilder.withPayload(user).build());
    }
}
